﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;

namespace Boss.Accounting.EntityFrameworkCore
{
    public class AccountingMigrationsDbContextFactory : IDesignTimeDbContextFactory<AccountingMigrationsDbContext>
    {
        public AccountingMigrationsDbContext CreateDbContext(string[] args)
        {
            var configuration = ConfigurationHelper.BuildConfiguration();

            var builder = new DbContextOptionsBuilder<AccountingMigrationsDbContext>()
                .UseSqlServer(configuration.GetConnectionString("Accounting"));

            return new AccountingMigrationsDbContext(builder.Options);
        }
    }
}
